#include<string>
#include<vector>
using namespace std;
class Solution1 {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string ret = strs[0];
        for (int i = 0; i < strs[0].size(); i++) {
            for (int j = 1; j < strs.size(); j++) {
                if (strs[j][i] != ret[i] || i == strs[j].size())return ret.substr(0, i);
            }
        }
        return strs[0];
    }
};
class Solution2 {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string ret = strs[0];
        for (int i = 0; i < strs.size() - 1; i++) {
            int size = strs[i].size() < strs[i + 1].size() ? strs[i].size()
                : strs[i + 1].size();
            int j;
            for (j = 0; j < size; j++) {
                if (strs[i][j] != strs[i + 1][j])break;
            }
            ret = strs[i].substr(0, j < ret.size() ? j : ret.size());
        }
        return ret;
    }
};
int main()
{
    return 0;
}